/**
 * 
 */
var params={};
$(function(){
	adaptive();
	params={size:2,type:2,title:$('#tag-search-field').val()};
	loadDataPageIetm("/ietm/tagsN", "srcoll-documentation", "lists",params);
	//书签搜索
	$('#tag-search').click(function(){
		$('#lists').html("");
		params={size:2,type:2,title:$('#tag-search-field').val()};
		loadDataPageIetm("/ietm/tagsN", "srcoll-documentation", "lists",params);
	});
	//书签
	$('#tags-edit').click(function(e) {		
		if($('li[class="active"][ownType="rows"]').length==1){
		var id=$('li[class="active"][ownType="rows"]').parent().attr("rowId");
		loadPage('/ietm/annotations/getObject?id='+id+"&page=tags-edit&"+new Date());
		
	}else{
		 $.Zebra_Dialog('<div class="prompt"><div class="warning-icon"></div><div class="success-title">请选中一条数据!</div></div>', {
	            'title':'提示',
	            'buttons':['确定']
	         });
	}});
	
	//书签删除
	$('#tags-del').on('click', function(e) {
		var  id="";
		$('li[class="active"][ownType="rows"]').each(function(){
			id += $(this).parent().attr("rowId")+",";
		});
		id=id.substring(0,id.length-1); 
		   
		 $.ajax({
	     type: "post",
	     url:"/ietm/commentTags/delete" ,
	     data:{id:id},
	     success: function (data, status) {
	    	 $.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">删除成功!</div></div>', {
		            'title':'提示',
		            'buttons':['确定']
		         });
	    	 loadPage(encodeURI("/ietm/tags?title="+$('#tag-search-field').val()));
	     },
	     error: function (data) {
	    	 $.Zebra_Dialog('<div class="prompt"><div class="error-icon"></div><div class="success-title">删除失败!</div></div>', {
		            'title':'提示',
		            'buttons':['确定']
		         });
	     }
	 });
		   
	 });
});
//构建数据列表--用于分页查询
function dataKk(data, me) {
	data=data.rows;
	var result = '';
	var arrLen = data.length;
	if (arrLen > 0) {
		for (var i = 0; i < arrLen; i++) {
			
			result +='<a dmId="'+data[i].dmodelId+'" rowId="'+data[i].id+'" projectId="'+data[i].projectId+'" onclick="dw(this)">'
					+'<li ownType="rows"><div class="paper-a">数据模块：'+data[i].code+'</div>'
					+'<div class="myplan-d">书签名：'+data[i].title+'</div><div class="documentation-check"></div></li></a>';
		}
	} else {
		me.lock();
		me.noData();
	}
	return result;
}
function dw(p){
	var params={
            dmId:$(p).attr("dmId"),
            projectId:$(p).attr("projectId"),
            type:"tag"
        };
	httpPost("/ietm/goDmUrl", params);
	
}